package com.rchik.divermate;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class RequiredRestDialog extends Dialog implements OnClickListener {
	
	private TextView messageTextView;
	private ImageView topMessageImageView;
	private ImageView bottomMessageImageView;
	
	public RequiredRestDialog(Context context) {
		super(context);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.requiredrestresult);
		((ImageButton)findViewById(R.id.OkButton)).setOnClickListener(this);
		messageTextView = ((TextView)findViewById(R.id.MessageTextView));
		topMessageImageView = (ImageView)findViewById(R.id.TopMessageImageView);
		bottomMessageImageView = (ImageView)findViewById(R.id.BottomMessageImageView);
	}
	
	@Override
	public void onClick(View arg0) {
		switch ( arg0.getId() )
		{
			case R.id.OkButton:
			{
				dismiss();
				break;
			}
			default:
			break;
		}
	}
	
	public void SetRequiredRestTime( int restTime )
	{
		if (restTime == 0)
		{
			topMessageImageView.setImageResource(R.drawable.rest_not_required);
			bottomMessageImageView.setVisibility(View.GONE);
			messageTextView.setVisibility(View.GONE);
			messageTextView.setText(R.string.rest_isnt_required);
		}
		else
		{				
			topMessageImageView.setImageResource(R.drawable.required_rest_for);
			bottomMessageImageView.setImageResource(R.drawable.required_rest_minutes);
			bottomMessageImageView.setVisibility(View.VISIBLE);
			messageTextView.setVisibility(View.VISIBLE);
			messageTextView.setText(restTime+"");
		}
	}
	
	public void Initialize() {
		
	}
}
